package com.gupao.gupaoeduvippattern.javaBase.a2Collection.demo01;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Muster {

    public static void main(String[] args) {
        Collection<String> collection = new ArrayList();
        collection.add("a");
        collection.add("b");
        collection.add("c");
        System.out.println(collection);

        //遍历集合
        Iterator<String> iterator = collection.iterator();
        int i = 0;
        System.out.println("==========Collection开始遍历集合=============");
        while(iterator.hasNext()){
            System.out.println(collection+","+iterator.next());
            iterator.remove();

//            System.out.println(iterator.next());
            /*i++;
            if(i > 10){
                break;
            }
            System.out.println(i);*/
        }

        System.out.println("==========Collection结束遍历集合=============");

        System.out.println(collection);

    }


    @Test
    public void test1(){
        Collection<String> coll = new ArrayList();
        coll.add("a");
        coll.add("b");
        coll.add("c");

        //
        System.out.println("集合是否为空："+coll.isEmpty());
        System.out.println("集合中元素的数量："+coll.size());



    }

}
